#include "mini_base.h"

#include "fxcc/imgui/Editor.h"
#include "fxcc/core/AssertManager.h"
#include "fxcc/mono/Maps.h"

template <>
bool fxcc::imgui::Editor::Edit<GameObject>(const std::string& label, GameObject& t)
{
    bool flag{ 0 };
    flag |= EditInst<std::string>("m_Name", t.m_Name);
    flag |= EditInst<fxcc::graph::common::Transform>("m_Transform", t.m_Transform);
    flag |= EditInst<fxcc::graph::common::MaterialView>("m_MaterialView", t.m_MaterialView);
    flag |= EditInst<fxcc::graph::common::MeshMap>("m_MeshMap", t.m_MeshMap);
    flag |= EditInst<mono::MonoBehivorMap>("m_MonoBehivorMap", t.m_MonoBehivorMap);
    return flag;
}

template <>
bool fxcc::imgui::Editor::Edit<DemoScene>(const std::string& label, DemoScene& t)
{
    bool flag{ 0 };
    for (auto& obj : t.m_GameObjects)
    {
        flag |= EditInst<GameObject>("GameObject", obj);
    }
    bool _add_obj_ = ImGui::Button("Add");

    if (_add_obj_)
    {
        GameObject gameObject;
        t.m_GameObjects.push_back(gameObject);
    }
    return flag;
};


template<>
void fxcc::yml::Serializer::Encode<GameObject>(YAML::Node& node, const GameObject& inst)
{
    SetVariable<std::string>(node, "m_Name", inst.m_Name);
    SetVariable<Transform>(node, "m_Tranform", inst.m_Transform);
    SetVariable<MaterialView>(node, "m_MaterialView", inst.m_MaterialView);
    SetVariable<MeshMap>(node, "m_MeshMap", inst.m_MeshMap);
    SetVariable<mono::MonoBehivorMap>(node, "m_MonoBehivorMap", inst.m_MonoBehivorMap);

}


template<>
bool fxcc::yml::Serializer::Decode<GameObject>(const YAML::Node& node, GameObject& inst)
{
    GetVariable<std::string>(node, "m_Name", inst.m_Name);
    GetVariable<Transform>(node, "m_Tranform", inst.m_Transform);
    GetVariable<MaterialView>(node, "m_MaterialView", inst.m_MaterialView);
    GetVariable<MeshMap>(node, "m_MeshMap", inst.m_MeshMap);
    GetVariable<mono::MonoBehivorMap>(node, "m_MonoBehivorMap", inst.m_MonoBehivorMap);
    return true;
}

template<>
void fxcc::yml::Serializer::Encode<DemoScene>(YAML::Node& node, const DemoScene& inst)
{
    SetArrayVariable<GameObject>(node, "m_GameObjects", inst.m_GameObjects);
}


template<>
bool fxcc::yml::Serializer::Decode<DemoScene>(const YAML::Node& node, DemoScene& inst)
{
    GetArrayVariable<GameObject>(node, "m_GameObjects", inst.m_GameObjects);
    return true;
}
